cc.Class({
    extends: cc.Component,

    properties: {
        prefabLevelItem: cc.Prefab,
        _labelLevelName: null,
        _levelItemcontent: null,
    },

    start() {
        this._labelLevelName = this.node.getChildByName("txt_levelname");
        this._levelItemcontent = this.node.getChildByName("img_levelitem_content");
    },
    /**
     * 创建时使用
     * @param {} data 
     */
    setLevelData(data) {
        if (data) {
            this._labelLevelName = data[0].gameScene;
            let itemList = data;
            var level = this.getGameData("level");//关卡
            this.unscheduleAllCallbacks();
            this.schedule(function () {
                //小于当前闯关数就显示关卡否则就是背景
                let isShowLevelNumber = itemList[index].level < level;
                let index = this._levelItemcontent.children.length;
                var objLevleItem = cc.instantiate(this.prefabLevelItem);
                let objLevleItemCom = objLevleItem.getComponent("LevelItem");
                objLevleItemCom.setListItemInfo(itemList[index], index);
                objLevleItemCom.setIsShowLevelNumber(isShowLevelNumber);
                this._levelItemcontent.addChild(objLevleItem);
            }, 0.1, itemList.length - 1);
        } else {
            cc.log("无关卡数据");
        }
    },
    /**
     * 更新关卡数据
     */
    updateLevelData(data,number){

    }

});